
package clientapp;

import javax.microedition.lcdui.*;

/**
 *
 */
public class SelectafdView extends List implements CommandListener {
    
    private ControllerMIDlet midlet;
    
    /**
     * constructor
     */
    public SelectafdView(ControllerMIDlet midlet) {
        super("Selecteer een afdeling", Choice.IMPLICIT);
        this.midlet = midlet;
       
        try {
            // Set up this list to listen to command events
            setCommandListener(this);
            // Add the Save command
            addCommand(new Command("back", Command.BACK, 1));
            addCommand(new Command("Selecteer", Command.OK, 2));
            
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
    
    /**
     * Called when action should be handled
     */
    public void commandAction(Command command, Displayable displayable) {
        if (command.getCommandType() == Command.BACK) {
            
            midlet.getMainView();
            this.deleteAll();
        }switch(command.getPriority()) {
           case 2: midlet.getoplView();
           midlet.setOpleiding(this.getSelectedIndex());
           break;
            
        }
    }

}
